package com.hspedu.newData.dmsxl.回溯.子集;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-19 
 * @Version: 1.0
 */

public class LC78子集 {

    List<List<Integer>> result = new ArrayList<>();
    List<Integer> path = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {

        backtracking(nums,0);
        return result;
    }

    public void backtracking(int[] nums,int startIndex){
        result.add(new ArrayList<>(path));

        if (startIndex >= nums.length){
            return;
        }

        for (int i = startIndex; i < nums.length; i++) {
            path.add(nums[i]);
            backtracking(nums,i+1);
            path.remove(path.size() - 1);
        }
    }

    @Test
    public void test() {
        // 测试代码

        List<List<Integer>> subsets = subsets(new int[]{1, 2, 3});

        System.out.println("111");
    }
}
